package com.openroom.ui.component;

import java.net.URL;

import org.apache.pivot.beans.BXML;
import org.apache.pivot.collections.Map;
import org.apache.pivot.util.Resources;
import org.apache.pivot.wtk.Component;
import org.apache.pivot.wtk.Panorama;

import com.openroom.ui.MainWindow;
import com.openroom.ui.NamespaceHelper;
import com.openroom.ui.UIComponent;

public class FullViewImageContainer extends Panorama implements UIComponent{

    @BXML
    ZoomablePreviewImage tnailPreviewImage1;
    
    public FullViewImageContainer() {
        this(null);
    }

    public FullViewImageContainer(Component view) {
        installSkin(FullViewImageContainer.class);
        setView(view);
    }

    public void setPosition(int x, int y) {
        int midH = getHeight() / 2;
        int midW = getWidth() / 2;
        int scrollTop = y - midH;
        setScrollTop(scrollTop >= 0 ? scrollTop : 0);
        int scrollLeft = x - midW;
        setScrollLeft(scrollLeft >= 0 ? scrollLeft : 0);
    }

    @Override
    public void initialize(Map<String, Object> namespace, URL arg1,
            Resources arg2, MainWindow window) {
        NamespaceHelper.initialize(namespace, this);
        System.out.println("FullViewImageContainer.initialize()");
        System.out.println(tnailPreviewImage1);
    }
    
    @Override
    protected void layout() {
        super.layout();
        tnailPreviewImage1.setScale(getWidth(),getHeight());
    }
    
}
